home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntinc20 / assert.h < prev    next >
C/C++ Source or Header  |  1992-05-15  |  1KB  |  60 lines

  1. /*
  2.  * assert.h
  3.  *    sec 4.2 ansi draft
  4.  */
  5.  
  6. /*
  7.  * 5/2/92 sb - changed __eprintf() to do its own work rather than calling
  8.  * fprintf(); this changed the calling sequence and made the __FAILED
  9.  * string unnecessary.
  10.  */
  11.  
  12. /* Allow this file to be included multiple times
  13.    with different settings of NDEBUG.  */
  14. #undef assert
  15. #ifndef _COMPILER_H
  16. #include <compiler.h>
  17. #endif
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. __EXTERN void __eprintf __PROTO((const char *, const long, const char *));
  24. __EXTERN void abort __PROTO((void));
  25.  
  26. #ifdef __cplusplus
  27. }
  28. #endif
  29.  
  30. #ifdef NDEBUG
  31. #define    assert(cond)
  32. #else
  33.  
  34. #ifdef __STDC__
  35. #define assert(cond) \
  36. if(!(cond)) { __eprintf(#cond, (long)__LINE__, __FILE__); abort(); }
  37.  
  38. #else
  39.  
  40. #ifndef __SOZOBON__
  41. /* There's a bug in Sozobon 2.0 whereby __LINE__ & __FILE__ are defined but
  42.  * testing #ifndef __?I?E__ comes out as if they aren't. */
  43.  
  44. #ifndef __LINE__
  45. #define __LINE__ 0
  46. #endif
  47. #ifndef __FILE__
  48. #define __FILE__ "unknown"
  49. #endif
  50.  
  51. #endif /* __SOZOBON__ */
  52.  
  53. #define assert(cond) \
  54. if(!(cond)) { __eprintf("cond", (long)__LINE__, __FILE__); abort(); }
  55.  
  56.  
  57. #endif /* __STDC__ */
  58.  
  59. #endif /* NDEBUG */
  60.